package com.lzx.activity.controller.web;

import com.lzx.activity.entity.Activity;
import com.lzx.activity.service.ActivityService;
import com.lzx.common.utils.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/activity/activity/web")
public class WebActivityController {
    @Resource
    private ActivityService activityService;

    //根据id查询活动
    @GetMapping("/{id}")
    public Activity getActivityById(@PathVariable Long id) {
        return activityService.getById(id);
    }

    //根据活动id查询活动和优惠券
    @GetMapping("/getActivityAndVoucher/{id}")
    public R getActivityAndVoucher(@PathVariable Long id) {
        return activityService.getActivityAndVoucher(id);
    }

    //获取活动列表
    @GetMapping("/list")
    public R list() {
        return activityService.getList();
    }
}
